home *** CD-ROM | disk | FTP | other *** search
/ Language/OS - Multiplatform Resource Library / LANGUAGE OS.iso / a_utils / perl / mac-perl / gdbm15st.bin / gdbm / gdbmdefs.h < prev    next >
MacBinary  |  1992-12-16  |  8.0 KB  |  [TEXT/MPS ]

open in: MacOS 8.1     |     Win98     |     DOS

browse contents    |     view JSON data     |     view as text


This file was processed as: MacBinary (archive/macBinary).

ConfidenceProgramDetectionMatch TypeSupport
10% dexvert MacBinary (archive/macBinary) fallback Supported
1% dexvert Text File (text/txt) fallback Supported
100% file MacBinary II, Tue Dec 15 23:31:26 1992, modified Tue Dec 15 23:31:26 1992, creator 'MPS ', type ASCII, 7537 bytes "gdbmdefs.h" , at 0x1df1 428 bytes resource default (weak)
99% file data default
74% TrID Macintosh plain text (MacBinary) default
25% TrID MacBinary 2 default (weak)
100% siegfried fmt/1762 MacBinary (II) default
100% lsar MacBinary default


id metadata
keyvalue
macFileType[TEXT]
macFileCreator[MPS ]



hex view
+--------+-------------------------+-------------------------+--------+--------+
|00000000| 00 0a 67 64 62 6d 64 65 | 66 73 2e 68 00 00 00 00 |..gdbmde|fs.h....|
|00000010| 00 00 00 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |........|........|
|00000020| 00 00 00 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |........|........|
|00000030| 00 00 00 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |........|........|
|00000040| 00 54 45 58 54 4d 50 53 | 20 00 00 00 00 00 00 00 |.TEXTMPS| .......|
|00000050| 00 00 00 00 00 1d 71 00 | 00 01 ac a7 54 61 9e a7 |......q.|....Ta..|
|00000060| 54 61 9e 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |Ta......|........|
|00000070| 00 00 00 00 00 00 00 00 | 00 00 81 81 d5 4d 00 00 |........|.....M..|
|00000080| 2f 2a 20 67 64 62 6d 64 | 65 66 73 2e 68 20 2d 20 |/* gdbmd|efs.h - |
|00000090| 54 68 65 20 69 6e 63 6c | 75 64 65 20 66 69 6c 65 |The incl|ude file|
|000000a0| 20 66 6f 72 20 64 62 6d | 2e 20 20 44 65 66 69 6e | for dbm|. Defin|
|000000b0| 65 73 20 73 74 72 75 63 | 74 75 72 65 20 61 6e 64 |es struc|ture and|
|000000c0| 20 63 6f 6e 73 74 61 6e | 74 73 2e 20 2a 2f 0d 0d | constan|ts. */..|
|000000d0| 2f 2a 20 20 54 68 69 73 | 20 66 69 6c 65 20 69 73 |/* This| file is|
|000000e0| 20 70 61 72 74 20 6f 66 | 20 47 44 42 4d 2c 20 74 | part of| GDBM, t|
|000000f0| 68 65 20 47 4e 55 20 64 | 61 74 61 20 62 61 73 65 |he GNU d|ata base|
|00000100| 20 6d 61 6e 61 67 65 72 | 2c 20 62 79 20 50 68 69 | manager|, by Phi|
|00000110| 6c 69 70 20 41 2e 20 4e | 65 6c 73 6f 6e 2e 0d 20 |lip A. N|elson.. |
|00000120| 20 20 20 43 6f 70 79 72 | 69 67 68 74 20 28 43 29 | Copyr|ight (C)|
|00000130| 20 31 39 39 30 2c 20 31 | 39 39 31 20 20 46 72 65 | 1990, 1|991 Fre|
|00000140| 65 20 53 6f 66 74 77 61 | 72 65 20 46 6f 75 6e 64 |e Softwa|re Found|
|00000150| 61 74 69 6f 6e 2c 20 49 | 6e 63 2e 0d 0d 20 20 20 |ation, I|nc... |
|00000160| 20 47 44 42 4d 20 69 73 | 20 66 72 65 65 20 73 6f | GDBM is| free so|
|00000170| 66 74 77 61 72 65 3b 20 | 79 6f 75 20 63 61 6e 20 |ftware; |you can |
|00000180| 72 65 64 69 73 74 72 69 | 62 75 74 65 20 69 74 20 |redistri|bute it |
|00000190| 61 6e 64 2f 6f 72 20 6d | 6f 64 69 66 79 0d 20 20 |and/or m|odify. |
|000001a0| 20 20 69 74 20 75 6e 64 | 65 72 20 74 68 65 20 74 | it und|er the t|
|000001b0| 65 72 6d 73 20 6f 66 20 | 74 68 65 20 47 4e 55 20 |erms of |the GNU |
|000001c0| 47 65 6e 65 72 61 6c 20 | 50 75 62 6c 69 63 20 4c |General |Public L|
|000001d0| 69 63 65 6e 73 65 20 61 | 73 20 70 75 62 6c 69 73 |icense a|s publis|
|000001e0| 68 65 64 20 62 79 0d 20 | 20 20 20 74 68 65 20 46 |hed by. | the F|
|000001f0| 72 65 65 20 53 6f 66 74 | 77 61 72 65 20 46 6f 75 |ree Soft|ware Fou|
|00000200| 6e 64 61 74 69 6f 6e 3b | 20 65 69 74 68 65 72 20 |ndation;| either |
|00000210| 76 65 72 73 69 6f 6e 20 | 31 2c 20 6f 72 20 28 61 |version |1, or (a|
|00000220| 74 20 79 6f 75 72 20 6f | 70 74 69 6f 6e 29 0d 20 |t your o|ption). |
|00000230| 20 20 20 61 6e 79 20 6c | 61 74 65 72 20 76 65 72 | any l|ater ver|
|00000240| 73 69 6f 6e 2e 0d 0d 20 | 20 20 20 47 44 42 4d 20 |sion... | GDBM |
|00000250| 69 73 20 64 69 73 74 72 | 69 62 75 74 65 64 20 69 |is distr|ibuted i|
|00000260| 6e 20 74 68 65 20 68 6f | 70 65 20 74 68 61 74 20 |n the ho|pe that |
|00000270| 69 74 20 77 69 6c 6c 20 | 62 65 20 75 73 65 66 75 |it will |be usefu|
|00000280| 6c 2c 0d 20 20 20 20 62 | 75 74 20 57 49 54 48 4f |l,. b|ut WITHO|
|00000290| 55 54 20 41 4e 59 20 57 | 41 52 52 41 4e 54 59 3b |UT ANY W|ARRANTY;|
|000002a0| 20 77 69 74 68 6f 75 74 | 20 65 76 65 6e 20 74 68 | without| even th|
|000002b0| 65 20 69 6d 70 6c 69 65 | 64 20 77 61 72 72 61 6e |e implie|d warran|
|000002c0| 74 79 20 6f 66 0d 20 20 | 20 20 4d 45 52 43 48 41 |ty of. | MERCHA|
|000002d0| 4e 54 41 42 49 4c 49 54 | 59 20 6f 72 20 46 49 54 |NTABILIT|Y or FIT|
|000002e0| 4e 45 53 53 20 46 4f 52 | 20 41 20 50 41 52 54 49 |NESS FOR| A PARTI|
|000002f0| 43 55 4c 41 52 20 50 55 | 52 50 4f 53 45 2e 20 20 |CULAR PU|RPOSE. |
|00000300| 53 65 65 20 74 68 65 0d | 20 20 20 20 47 4e 55 20 |See the.| GNU |
|00000310| 47 65 6e 65 72 61 6c 20 | 50 75 62 6c 69 63 20 4c |General |Public L|
|00000320| 69 63 65 6e 73 65 20 66 | 6f 72 20 6d 6f 72 65 20 |icense f|or more |
|00000330| 64 65 74 61 69 6c 73 2e | 0d 0d 20 20 20 20 59 6f |details.|.. Yo|
|00000340| 75 20 73 68 6f 75 6c 64 | 20 68 61 76 65 20 72 65 |u should| have re|
|00000350| 63 65 69 76 65 64 20 61 | 20 63 6f 70 79 20 6f 66 |ceived a| copy of|
|00000360| 20 74 68 65 20 47 4e 55 | 20 47 65 6e 65 72 61 6c | the GNU| General|
|00000370| 20 50 75 62 6c 69 63 20 | 4c 69 63 65 6e 73 65 0d | Public |License.|
|00000380| 20 20 20 20 61 6c 6f 6e | 67 20 77 69 74 68 20 47 | alon|g with G|
|00000390| 44 42 4d 3b 20 73 65 65 | 20 74 68 65 20 66 69 6c |DBM; see| the fil|
|000003a0| 65 20 43 4f 50 59 49 4e | 47 2e 20 20 49 66 20 6e |e COPYIN|G. If n|
|000003b0| 6f 74 2c 20 77 72 69 74 | 65 20 74 6f 0d 20 20 20 |ot, writ|e to. |
|000003c0| 20 74 68 65 20 46 72 65 | 65 20 53 6f 66 74 77 61 | the Fre|e Softwa|
|000003d0| 72 65 20 46 6f 75 6e 64 | 61 74 69 6f 6e 2c 20 36 |re Found|ation, 6|
|000003e0| 37 35 20 4d 61 73 73 20 | 41 76 65 2c 20 43 61 6d |75 Mass |Ave, Cam|
|000003f0| 62 72 69 64 67 65 2c 20 | 4d 41 20 30 32 31 33 39 |bridge, |MA 02139|
|00000400| 2c 20 55 53 41 2e 0d 0d | 20 20 20 20 59 6f 75 20 |, USA...| You |
|00000410| 6d 61 79 20 63 6f 6e 74 | 61 63 74 20 74 68 65 20 |may cont|act the |
|00000420| 61 75 74 68 6f 72 20 62 | 79 3a 0d 20 20 20 20 20 |author b|y:. |
|00000430| 20 20 65 2d 6d 61 69 6c | 3a 20 20 70 68 69 6c 40 | e-mail|: phil@|
|00000440| 63 73 2e 77 77 75 2e 65 | 64 75 0d 20 20 20 20 20 |cs.wwu.e|du. |
|00000450| 20 75 73 2d 6d 61 69 6c | 3a 20 20 50 68 69 6c 69 | us-mail|: Phili|
|00000460| 70 20 41 2e 20 4e 65 6c | 73 6f 6e 0d 20 20 20 20 |p A. Nel|son. |
|00000470| 20 20 20 20 20 20 20 20 | 20 20 20 20 43 6f 6d 70 | | Comp|
|00000480| 75 74 65 72 20 53 63 69 | 65 6e 63 65 20 44 65 70 |uter Sci|ence Dep|
|00000490| 61 72 74 6d 65 6e 74 0d | 20 20 20 20 20 20 20 20 |artment.| |
|000004a0| 20 20 20 20 20 20 20 20 | 57 65 73 74 65 72 6e 20 | |Western |
|000004b0| 57 61 73 68 69 6e 67 74 | 6f 6e 20 55 6e 69 76 65 |Washingt|on Unive|
|000004c0| 72 73 69 74 79 0d 20 20 | 20 20 20 20 20 20 20 20 |rsity. | |
|000004d0| 20 20 20 20 20 20 42 65 | 6c 6c 69 6e 67 68 61 6d | Be|llingham|
|000004e0| 2c 20 57 41 20 39 38 32 | 32 36 0d 20 20 20 20 20 |, WA 982|26. |
|000004f0| 20 20 20 70 68 6f 6e 65 | 3a 20 20 28 32 30 36 29 | phone|: (206)|
|00000500| 20 36 37 36 2d 33 30 33 | 35 0d 2a 2a 2a 2a 2a 2a | 676-303|5.******|
|00000510| 2a 2a 2a 2a 2a 2a 2a 2a | 2a 2a 2a 2a 2a 2a 2a 2a |********|********|
|00000520| 2a 2a 2a 2a 2a 2a 2a 2a | 2a 2a 2a 2a 2a 2a 2a 2a |********|********|
|00000530| 2a 2a 2a 2a 2a 2a 2a 2a | 2a 2a 2a 2a 2a 2a 2a 2a |********|********|
|00000540| 2a 2a 2a 2a 2a 2a 2a 2a | 2a 2a 2a 2a 2a 2a 2a 2a |********|********|
|00000550| 2a 2a 2a 2f 0d 0d 0d 2f | 2a 20 49 6e 63 6c 75 64 |***/.../|* Includ|
|00000560| 65 20 74 68 65 20 73 74 | 61 6e 64 61 72 64 20 69 |e the st|andard i|
|00000570| 6e 63 6c 75 64 65 20 66 | 69 6c 65 73 20 6e 65 65 |nclude f|iles nee|
|00000580| 64 65 64 20 66 6f 72 20 | 67 64 62 6d 2e 20 2a 2f |ded for |gdbm. */|
|00000590| 0d 23 69 6e 63 6c 75 64 | 65 20 3c 73 74 64 69 6f |.#includ|e <stdio|
|000005a0| 2e 68 3e 0d 0d 23 69 66 | 64 65 66 20 6d 61 63 69 |.h>..#if|def maci|
|000005b0| 6e 74 6f 73 68 0d 23 69 | 6e 63 6c 75 64 65 20 3c |ntosh.#i|nclude <|
|000005c0| 66 63 6e 74 6c 2e 68 3e | 0d 23 69 6e 63 6c 75 64 |fcntl.h>|.#includ|
|000005d0| 65 20 3c 73 79 73 2f 73 | 74 61 74 2e 68 3e 0d 23 |e <sys/s|tat.h>.#|
|000005e0| 65 6c 73 65 0d 23 69 6e | 63 6c 75 64 65 20 3c 73 |else.#in|clude <s|
|000005f0| 79 73 2f 74 79 70 65 73 | 2e 68 3e 0d 23 69 6e 63 |ys/types|.h>.#inc|
|00000600| 6c 75 64 65 20 3c 73 79 | 73 2f 66 69 6c 65 2e 68 |lude <sy|s/file.h|
|00000610| 3e 0d 23 69 6e 63 6c 75 | 64 65 20 3c 73 79 73 2f |>.#inclu|de <sys/|
|00000620| 73 74 61 74 2e 68 3e 0d | 23 65 6e 64 69 66 0d 0d |stat.h>.|#endif..|
|00000630| 23 69 6e 63 6c 75 64 65 | 20 22 67 64 62 6d 63 6f |#include| "gdbmco|
|00000640| 6e 73 74 2e 68 22 0d 23 | 69 6e 63 6c 75 64 65 20 |nst.h".#|include |
|00000650| 22 73 79 73 74 65 6d 73 | 2e 68 22 0d 0d 2f 2a 20 |"systems|.h"../* |
|00000660| 54 68 65 20 74 79 70 65 | 20 64 65 66 69 6e 69 74 |The type| definit|
|00000670| 69 6f 6e 73 20 61 72 65 | 20 6e 65 78 74 2e 20 20 |ions are| next. |
|00000680| 2a 2f 0d 0d 2f 2a 20 54 | 68 65 20 64 61 74 61 20 |*/../* T|he data |
|00000690| 61 6e 64 20 6b 65 79 20 | 73 74 72 75 63 74 75 72 |and key |structur|
|000006a0| 65 2e 20 20 54 68 69 73 | 20 73 74 72 75 63 74 75 |e. This| structu|
|000006b0| 72 65 20 69 73 20 64 65 | 66 69 6e 65 64 20 66 6f |re is de|fined fo|
|000006c0| 72 20 63 6f 6d 70 61 74 | 69 62 69 6c 69 74 79 2e |r compat|ibility.|
|000006d0| 20 2a 2f 0d 0d 74 79 70 | 65 64 65 66 20 73 74 72 | */..typ|edef str|
|000006e0| 75 63 74 20 7b 0d 09 63 | 68 61 72 20 2a 64 70 74 |uct {..c|har *dpt|
|000006f0| 72 3b 0d 09 69 6e 74 20 | 20 20 64 73 69 7a 65 3b |r;..int | dsize;|
|00000700| 0d 20 20 20 20 20 20 7d | 20 64 61 74 75 6d 3b 0d |. }| datum;.|
|00000710| 0d 0d 2f 2a 20 54 68 65 | 20 61 76 61 69 6c 61 62 |../* The| availab|
|00000720| 6c 65 20 66 69 6c 65 20 | 73 70 61 63 65 20 69 73 |le file |space is|
|00000730| 20 73 74 6f 72 65 64 20 | 69 6e 20 61 6e 20 22 61 | stored |in an "a|
|00000740| 76 61 69 6c 22 20 74 61 | 62 6c 65 2e 20 20 54 68 |vail" ta|ble. Th|
|00000750| 65 20 6f 6e 65 20 77 69 | 74 68 0d 20 20 20 6d 6f |e one wi|th. mo|
|00000760| 73 74 20 61 63 74 69 76 | 69 74 79 20 69 73 20 63 |st activ|ity is c|
|00000770| 6f 6e 74 61 69 6e 65 64 | 20 69 6e 20 74 68 65 20 |ontained| in the |
|00000780| 66 69 6c 65 20 68 65 61 | 64 65 72 2e 20 28 53 65 |file hea|der. (Se|
|00000790| 65 20 62 65 6c 6f 77 2e | 29 20 20 57 68 65 6e 20 |e below.|) When |
|000007a0| 74 68 61 74 0d 20 20 20 | 6f 6e 65 20 66 69 6c 6c |that. |one fill|
|000007b0| 65 73 20 75 70 2c 20 69 | 74 20 69 73 20 73 70 6c |es up, i|t is spl|
|000007c0| 69 74 20 69 6e 20 68 61 | 6c 66 20 61 6e 64 20 68 |it in ha|lf and h|
|000007d0| 61 6c 66 20 69 73 20 70 | 75 73 68 65 64 20 6f 6e |alf is p|ushed on|
|000007e0| 20 61 6e 20 22 61 76 61 | 69 6c 0d 20 20 20 73 74 | an "ava|il. st|
|000007f0| 61 63 6b 2e 22 20 20 57 | 68 65 6e 20 74 68 65 20 |ack." W|hen the |
|00000800| 61 63 74 69 76 65 20 61 | 76 61 69 6c 20 74 61 62 |active a|vail tab|
|00000810| 6c 65 20 69 73 20 65 6d | 70 74 79 20 61 6e 64 20 |le is em|pty and |
|00000820| 74 68 65 20 22 61 76 61 | 69 6c 20 73 74 61 63 6b |the "ava|il stack|
|00000830| 22 20 69 73 0d 20 20 20 | 6e 6f 74 20 65 6d 70 74 |" is. |not empt|
|00000840| 79 2c 20 74 68 65 20 74 | 6f 70 20 6f 66 20 74 68 |y, the t|op of th|
|00000850| 65 20 73 74 61 63 6b 20 | 69 73 20 70 6f 70 70 65 |e stack |is poppe|
|00000860| 64 20 69 6e 74 6f 20 74 | 68 65 20 61 63 74 69 76 |d into t|he activ|
|00000870| 65 20 61 76 61 69 6c 20 | 74 61 62 6c 65 2e 20 2a |e avail |table. *|
|00000880| 2f 0d 0d 2f 2a 20 54 68 | 65 20 66 6f 6c 6c 6f 77 |/../* Th|e follow|
|00000890| 69 6e 67 20 73 74 72 75 | 63 74 75 72 65 20 69 73 |ing stru|cture is|
|000008a0| 20 74 68 65 20 65 6c 65 | 6d 65 6e 74 20 6f 66 20 | the ele|ment of |
|000008b0| 74 68 65 20 61 76 61 6c | 69 61 62 6c 65 20 74 61 |the aval|iable ta|
|000008c0| 62 6c 65 2e 20 20 2a 2f | 0d 74 79 70 65 64 65 66 |ble. */|.typedef|
|000008d0| 20 73 74 72 75 63 74 20 | 7b 0d 20 20 09 69 6e 74 | struct |{. .int|
|000008e0| 20 20 20 61 76 5f 73 69 | 7a 65 3b 09 09 2f 2a 20 | av_si|ze;../* |
|000008f0| 54 68 65 20 73 69 7a 65 | 20 6f 66 20 74 68 65 20 |The size| of the |
|00000900| 61 76 61 69 6c 61 62 6c | 65 20 62 6c 6f 63 6b 2e |availabl|e block.|
|00000910| 20 2a 2f 0d 09 6c 6f 6e | 67 20 20 61 76 5f 61 64 | */..lon|g av_ad|
|00000920| 72 3b 09 09 2f 2a 20 54 | 68 65 20 66 69 6c 65 20 |r;../* T|he file |
|00000930| 61 64 64 72 65 73 73 20 | 6f 66 20 74 68 65 20 61 |address |of the a|
|00000940| 76 61 69 6c 61 62 6c 65 | 20 62 6c 6f 63 6b 2e 20 |vailable| block. |
|00000950| 2a 2f 0d 20 20 20 20 20 | 20 7d 20 61 76 61 69 6c |*/. | } avail|
|00000960| 5f 65 6c 65 6d 3b 0d 0d | 2f 2a 20 54 68 69 73 20 |_elem;..|/* This |
|00000970| 69 73 20 74 68 65 20 61 | 63 74 75 61 6c 20 74 61 |is the a|ctual ta|
|00000980| 62 6c 65 2e 20 54 68 65 | 20 69 6e 2d 6d 65 6d 6f |ble. The| in-memo|
|00000990| 72 79 20 69 6d 61 67 65 | 73 20 6f 66 20 74 68 65 |ry image|s of the|
|000009a0| 20 61 76 61 69 6c 20 62 | 6c 6f 63 6b 73 20 61 72 | avail b|locks ar|
|000009b0| 65 0d 20 20 20 61 6c 6c | 6f 63 61 74 65 64 20 62 |e. all|ocated b|
|000009c0| 79 20 6d 61 6c 6c 6f 63 | 20 75 73 69 6e 67 20 61 |y malloc| using a|
|000009d0| 20 63 61 6c 63 75 6c 61 | 74 65 64 20 73 69 7a 65 | calcula|ted size|
|000009e0| 2e 20 20 2a 2f 0d 74 79 | 70 65 64 65 66 20 73 74 |. */.ty|pedef st|
|000009f0| 72 75 63 74 20 7b 0d 09 | 69 6e 74 20 20 20 73 69 |ruct {..|int si|
|00000a00| 7a 65 3b 09 09 2f 2a 20 | 54 68 65 20 6e 75 6d 62 |ze;../* |The numb|
|00000a10| 65 72 20 6f 66 20 61 76 | 61 69 6c 20 65 6c 65 6d |er of av|ail elem|
|00000a20| 65 6e 74 73 20 69 6e 20 | 74 68 65 20 74 61 62 6c |ents in |the tabl|
|00000a30| 65 2e 2a 2f 0d 09 69 6e | 74 20 20 20 63 6f 75 6e |e.*/..in|t coun|
|00000a40| 74 3b 09 09 2f 2a 20 54 | 68 65 20 6e 75 6d 62 65 |t;../* T|he numbe|
|00000a50| 72 20 6f 66 20 65 6e 74 | 72 69 65 73 20 69 6e 20 |r of ent|ries in |
|00000a60| 74 68 65 20 74 61 62 6c | 65 2e 20 2a 2f 0d 09 6c |the tabl|e. */..l|
|00000a70| 6f 6e 67 20 20 6e 65 78 | 74 5f 62 6c 6f 63 6b 3b |ong nex|t_block;|
|00000a80| 09 2f 2a 20 54 68 65 20 | 66 69 6c 65 20 61 64 64 |./* The |file add|
|00000a90| 72 65 73 73 20 6f 66 20 | 74 68 65 20 6e 65 78 74 |ress of |the next|
|00000aa0| 20 61 76 61 69 6c 20 62 | 6c 6f 63 6b 2e 20 2a 2f | avail b|lock. */|
|00000ab0| 0d 09 61 76 61 69 6c 5f | 65 6c 65 6d 20 61 76 5f |..avail_|elem av_|
|00000ac0| 74 61 62 6c 65 5b 31 5d | 3b 20 2f 2a 20 54 68 65 |table[1]|; /* The|
|00000ad0| 20 74 61 62 6c 65 2e 20 | 20 4d 61 6b 65 20 69 74 | table. | Make it|
|00000ae0| 20 6c 6f 6f 6b 20 6c 69 | 6b 65 20 61 6e 20 61 72 | look li|ke an ar|
|00000af0| 72 61 79 2e 20 20 2a 2f | 0d 20 20 20 20 20 20 7d |ray. */|. }|
|00000b00| 20 61 76 61 69 6c 5f 62 | 6c 6f 63 6b 3b 0d 0d 2f | avail_b|lock;../|
|00000b10| 2a 20 54 68 65 20 64 62 | 6d 20 66 69 6c 65 20 68 |* The db|m file h|
|00000b20| 65 61 64 65 72 20 6b 65 | 65 70 73 20 74 72 61 63 |eader ke|eps trac|
|00000b30| 6b 20 6f 66 20 74 68 65 | 20 63 75 72 72 65 6e 74 |k of the| current|
|00000b40| 20 6c 6f 63 61 74 69 6f | 6e 20 6f 66 20 74 68 65 | locatio|n of the|
|00000b50| 20 68 61 73 68 0d 20 20 | 20 64 69 72 65 63 74 6f | hash. | directo|
|00000b60| 72 79 20 61 6e 64 20 74 | 68 65 20 66 72 65 65 20 |ry and t|he free |
|00000b70| 73 70 61 63 65 20 69 6e | 20 74 68 65 20 66 69 6c |space in| the fil|
|00000b80| 65 2e 20 20 2a 2f 0d 0d | 74 79 70 65 64 65 66 20 |e. */..|typedef |
|00000b90| 73 74 72 75 63 74 20 7b | 0d 09 6c 6f 6e 67 20 20 |struct {|..long |
|00000ba0| 68 65 61 64 65 72 5f 6d | 61 67 69 63 3b 20 20 2f |header_m|agic; /|
|00000bb0| 2a 20 30 78 31 33 35 37 | 39 61 63 65 20 74 6f 20 |* 0x1357|9ace to |
|00000bc0| 6d 61 6b 65 20 73 75 72 | 65 20 74 68 65 20 68 65 |make sur|e the he|
|00000bd0| 61 64 65 72 20 69 73 20 | 67 6f 6f 64 2e 20 2a 2f |ader is |good. */|
|00000be0| 0d 09 69 6e 74 20 20 20 | 62 6c 6f 63 6b 5f 73 69 |..int |block_si|
|00000bf0| 7a 65 3b 20 20 20 20 2f | 2a 20 54 68 65 20 20 6f |ze; /|* The o|
|00000c00| 70 74 69 6d 61 6c 20 69 | 2f 6f 20 62 6c 6f 63 6b |ptimal i|/o block|
|00000c10| 73 69 7a 65 20 66 72 6f | 6d 20 73 74 61 74 2e 20 |size fro|m stat. |
|00000c20| 2a 2f 0d 09 6c 6f 6e 67 | 20 20 64 69 72 3b 09 20 |*/..long| dir;. |
|00000c30| 20 20 20 20 2f 2a 20 46 | 69 6c 65 20 61 64 64 72 | /* F|ile addr|
|00000c40| 65 73 73 20 6f 66 20 68 | 61 73 68 20 64 69 72 65 |ess of h|ash dire|
|00000c50| 63 74 6f 72 79 20 74 61 | 62 6c 65 2e 20 2a 2f 0d |ctory ta|ble. */.|
|00000c60| 09 69 6e 74 20 20 20 64 | 69 72 5f 73 69 7a 65 3b |.int d|ir_size;|
|00000c70| 09 20 20 20 20 20 2f 2a | 20 53 69 7a 65 20 69 6e |. /*| Size in|
|00000c80| 20 62 79 74 65 73 20 6f | 66 20 74 68 65 20 74 61 | bytes o|f the ta|
|00000c90| 62 6c 65 2e 20 20 2a 2f | 0d 09 69 6e 74 20 20 20 |ble. */|..int |
|00000ca0| 64 69 72 5f 62 69 74 73 | 3b 09 20 20 20 20 20 2f |dir_bits|;. /|
|00000cb0| 2a 20 54 68 65 20 6e 75 | 6d 62 65 72 20 6f 66 20 |* The nu|mber of |
|00000cc0| 61 64 64 72 65 73 73 20 | 62 69 74 73 20 75 73 65 |address |bits use|
|00000cd0| 64 20 69 6e 20 74 68 65 | 20 74 61 62 6c 65 2e 2a |d in the| table.*|
|00000ce0| 2f 0d 09 69 6e 74 20 20 | 20 62 75 63 6b 65 74 5f |/..int | bucket_|
|00000cf0| 73 69 7a 65 3b 20 20 20 | 2f 2a 20 53 69 7a 65 20 |size; |/* Size |
|00000d00| 69 6e 20 62 79 74 65 73 | 20 6f 66 20 61 20 68 61 |in bytes| of a ha|
|00000d10| 73 68 20 62 75 63 6b 65 | 74 20 73 74 72 75 63 74 |sh bucke|t struct|
|00000d20| 2e 20 2a 2f 0d 09 69 6e | 74 20 20 20 62 75 63 6b |. */..in|t buck|
|00000d30| 65 74 5f 65 6c 65 6d 73 | 3b 20 20 2f 2a 20 4e 75 |et_elems|; /* Nu|
|00000d40| 6d 62 65 72 20 6f 66 20 | 65 6c 65 6d 65 6e 74 73 |mber of |elements|
|00000d50| 20 69 6e 20 61 20 68 61 | 73 68 20 62 75 63 6b 65 | in a ha|sh bucke|
|00000d60| 74 2e 20 2a 2f 0d 09 6c | 6f 6e 67 20 20 6e 65 78 |t. */..l|ong nex|
|00000d70| 74 5f 62 6c 6f 63 6b 3b | 20 20 20 20 2f 2a 20 54 |t_block;| /* T|
|00000d80| 68 65 20 6e 65 78 74 20 | 75 6e 61 6c 6c 6f 63 61 |he next |unalloca|
|00000d90| 74 65 64 20 62 6c 6f 63 | 6b 20 61 64 64 72 65 73 |ted bloc|k addres|
|00000da0| 73 2e 20 2a 2f 0d 09 61 | 76 61 69 6c 5f 62 6c 6f |s. */..a|vail_blo|
|00000db0| 63 6b 20 61 76 61 69 6c | 3b 20 20 20 2f 2a 20 54 |ck avail|; /* T|
|00000dc0| 68 69 73 20 6d 75 73 74 | 20 62 65 20 6c 61 73 74 |his must| be last|
|00000dd0| 20 62 65 63 61 75 73 65 | 20 6f 66 20 74 68 65 20 | because| of the |
|00000de0| 70 73 75 65 64 6f 0d 09 | 09 09 09 61 72 72 61 79 |psuedo..|...array|
|00000df0| 20 69 6e 20 61 76 61 69 | 6c 2e 20 20 54 68 69 73 | in avai|l. This|
|00000e00| 20 61 76 61 69 6c 20 67 | 72 6f 77 73 20 74 6f 20 | avail g|rows to |
|00000e10| 66 69 6c 6c 0d 09 09 09 | 09 74 68 65 20 65 6e 74 |fill....|.the ent|
|00000e20| 69 72 65 20 62 6c 6f 63 | 6b 2e 20 2a 2f 0d 20 20 |ire bloc|k. */. |
|00000e30| 20 20 20 20 7d 20 20 67 | 64 62 6d 5f 66 69 6c 65 | } g|dbm_file|
|00000e40| 5f 68 65 61 64 65 72 3b | 0d 0d 0d 2f 2a 20 54 68 |_header;|.../* Th|
|00000e50| 65 20 64 62 6d 20 68 61 | 73 68 20 62 75 63 6b 65 |e dbm ha|sh bucke|
|00000e60| 74 20 65 6c 65 6d 65 6e | 74 20 63 6f 6e 74 61 69 |t elemen|t contai|
|00000e70| 6e 73 20 74 68 65 20 66 | 75 6c 6c 20 33 31 20 62 |ns the f|ull 31 b|
|00000e80| 69 74 20 68 61 73 68 20 | 76 61 6c 75 65 2c 20 74 |it hash |value, t|
|00000e90| 68 65 0d 20 20 20 22 70 | 6f 69 6e 74 65 72 22 20 |he. "p|ointer" |
|00000ea0| 74 6f 20 74 68 65 20 6b | 65 79 20 61 6e 64 20 64 |to the k|ey and d|
|00000eb0| 61 74 61 20 28 73 74 6f | 72 65 64 20 74 6f 67 65 |ata (sto|red toge|
|00000ec0| 74 68 65 72 29 20 77 69 | 74 68 20 74 68 65 69 72 |ther) wi|th their|
|00000ed0| 20 73 69 7a 65 73 2e 20 | 20 49 74 20 61 6c 73 6f | sizes. | It also|
|00000ee0| 0d 20 20 20 68 61 73 20 | 61 20 73 6d 61 6c 6c 20 |. has |a small |
|00000ef0| 70 61 72 74 20 6f 66 20 | 74 68 65 20 61 63 74 75 |part of |the actu|
|00000f00| 61 6c 20 6b 65 79 20 76 | 61 6c 75 65 2e 20 20 49 |al key v|alue. I|
|00000f10| 74 20 69 73 20 75 73 65 | 64 20 74 6f 20 76 65 72 |t is use|d to ver|
|00000f20| 69 66 79 20 74 68 65 20 | 66 69 72 73 74 0d 20 20 |ify the |first. |
|00000f30| 20 70 61 72 74 20 6f 66 | 20 74 68 65 20 6b 65 79 | part of| the key|
|00000f40| 20 68 61 73 20 74 68 65 | 20 63 6f 72 72 65 63 74 | has the| correct|
|00000f50| 20 76 61 6c 75 65 20 77 | 69 74 68 6f 75 74 20 68 | value w|ithout h|
|00000f60| 61 76 69 6e 67 20 74 6f | 20 72 65 61 64 20 74 68 |aving to| read th|
|00000f70| 65 20 61 63 74 75 61 6c | 0d 20 20 20 6b 65 79 2e |e actual|. key.|
|00000f80| 20 2a 2f 0d 0d 74 79 70 | 65 64 65 66 20 73 74 72 | */..typ|edef str|
|00000f90| 75 63 74 20 7b 0d 09 6c | 6f 6e 67 20 20 68 61 73 |uct {..l|ong has|
|00000fa0| 68 5f 76 61 6c 75 65 3b | 09 2f 2a 20 54 68 65 20 |h_value;|./* The |
|00000fb0| 63 6f 6d 70 6c 65 74 65 | 20 33 31 20 62 69 74 20 |complete| 31 bit |
|00000fc0| 76 61 6c 75 65 2e 20 2a | 2f 0d 09 63 68 61 72 20 |value. *|/..char |
|00000fd0| 20 6b 65 79 5f 73 74 61 | 72 74 5b 53 4d 41 4c 4c | key_sta|rt[SMALL|
|00000fe0| 5d 3b 09 2f 2a 20 55 70 | 20 74 6f 20 74 68 65 20 |];./* Up| to the |
|00000ff0| 66 69 72 73 74 20 53 4d | 41 4c 4c 20 62 79 74 65 |first SM|ALL byte|
|00001000| 73 20 6f 66 20 74 68 65 | 20 6b 65 79 2e 20 20 2a |s of the| key. *|
|00001010| 2f 0d 09 6c 6f 6e 67 20 | 20 64 61 74 61 5f 70 6f |/..long | data_po|
|00001020| 69 6e 74 65 72 3b 09 2f | 2a 20 54 68 65 20 66 69 |inter;./|* The fi|
|00001030| 6c 65 20 61 64 64 72 65 | 73 73 20 6f 66 20 74 68 |le addre|ss of th|
|00001040| 65 20 6b 65 79 20 72 65 | 63 6f 72 64 2e 20 54 68 |e key re|cord. Th|
|00001050| 65 0d 09 09 09 09 20 20 | 20 64 61 74 61 20 72 65 |e..... | data re|
|00001060| 63 6f 72 64 20 64 69 72 | 65 63 74 6c 79 20 66 6f |cord dir|ectly fo|
|00001070| 6c 6c 6f 77 73 20 74 68 | 65 20 6b 65 79 2e 20 20 |llows th|e key. |
|00001080| 2a 2f 0d 09 69 6e 74 20 | 20 20 6b 65 79 5f 73 69 |*/..int | key_si|
|00001090| 7a 65 3b 09 09 2f 2a 20 | 53 69 7a 65 20 6f 66 20 |ze;../* |Size of |
|000010a0| 6b 65 79 20 64 61 74 61 | 20 69 6e 20 74 68 65 20 |key data| in the |
|000010b0| 66 69 6c 65 2e 20 2a 2f | 0d 09 69 6e 74 20 20 20 |file. */|..int |
|000010c0| 64 61 74 61 5f 73 69 7a | 65 3b 09 2f 2a 20 53 69 |data_siz|e;./* Si|
|000010d0| 7a 65 20 6f 66 20 61 73 | 73 6f 63 69 61 74 65 64 |ze of as|sociated|
|000010e0| 20 64 61 74 61 20 69 6e | 20 74 68 65 20 66 69 6c | data in| the fil|
|000010f0| 65 2e 20 2a 2f 0d 20 20 | 20 20 20 20 7d 20 62 75 |e. */. | } bu|
|00001100| 63 6b 65 74 5f 65 6c 65 | 6d 65 6e 74 3b 0d 0d 0d |cket_ele|ment;...|
|00001110| 2f 2a 20 41 20 62 75 63 | 6b 65 74 20 69 73 20 61 |/* A buc|ket is a|
|00001120| 20 73 6d 61 6c 6c 20 68 | 61 73 68 20 74 61 62 6c | small h|ash tabl|
|00001130| 65 2e 20 20 54 68 69 73 | 20 6f 6e 65 20 63 6f 6e |e. This| one con|
|00001140| 73 69 73 74 73 20 6f 66 | 20 61 20 6e 75 6d 62 65 |sists of| a numbe|
|00001150| 72 20 6f 66 0d 20 20 20 | 62 75 63 6b 65 74 20 65 |r of. |bucket e|
|00001160| 6c 65 6d 65 6e 74 73 20 | 70 6c 75 73 20 73 6f 6d |lements |plus som|
|00001170| 65 20 62 6f 6f 6b 6b 65 | 65 70 69 6e 67 20 66 69 |e bookke|eping fi|
|00001180| 65 6c 64 73 2e 20 20 54 | 68 65 20 6e 75 6d 62 65 |elds. T|he numbe|
|00001190| 72 20 6f 66 20 65 6c 65 | 6d 65 6e 74 73 0d 20 20 |r of ele|ments. |
|000011a0| 20 64 65 70 65 6e 64 73 | 20 6f 6e 20 74 68 65 20 | depends| on the |
|000011b0| 6f 70 74 69 6d 75 6d 20 | 62 6c 6f 63 6b 73 69 7a |optimum |blocksiz|
|000011c0| 65 20 66 6f 72 20 74 68 | 65 20 73 74 6f 72 61 67 |e for th|e storag|
|000011d0| 65 20 64 65 76 69 63 65 | 20 61 6e 64 20 6f 6e 20 |e device| and on |
|000011e0| 61 0d 20 20 20 70 61 72 | 61 6d 65 74 65 72 20 67 |a. par|ameter g|
|000011f0| 69 76 65 6e 20 61 74 20 | 66 69 6c 65 20 63 72 65 |iven at |file cre|
|00001200| 61 74 69 6f 6e 20 74 69 | 6d 65 2e 20 20 54 68 69 |ation ti|me. Thi|
|00001210| 73 20 62 75 63 6b 65 74 | 20 74 61 6b 65 73 20 6f |s bucket| takes o|
|00001220| 6e 65 20 62 6c 6f 63 6b | 2e 0d 20 20 20 57 68 65 |ne block|.. Whe|
|00001230| 6e 20 6f 6e 65 20 6f 66 | 20 74 68 65 73 65 20 74 |n one of| these t|
|00001240| 61 62 6c 65 73 20 67 65 | 74 73 20 66 75 6c 6c 2c |ables ge|ts full,|
|00001250| 20 69 74 20 69 73 20 73 | 70 6c 69 74 20 69 6e 74 | it is s|plit int|
|00001260| 6f 20 74 77 6f 20 68 61 | 73 68 20 62 75 63 6b 65 |o two ha|sh bucke|
|00001270| 74 73 2e 0d 20 20 20 54 | 68 65 20 63 6f 6e 74 65 |ts.. T|he conte|
|00001280| 6e 74 73 20 61 72 65 20 | 73 70 6c 69 74 20 62 65 |nts are |split be|
|00001290| 74 77 65 65 6e 20 74 68 | 65 6d 20 62 79 20 74 68 |tween th|em by th|
|000012a0| 65 20 75 73 65 20 6f 66 | 20 74 68 65 20 66 69 72 |e use of| the fir|
|000012b0| 73 74 20 66 65 77 20 62 | 69 74 73 0d 20 20 20 6f |st few b|its. o|
|000012c0| 66 20 74 68 65 20 33 31 | 20 62 69 74 20 68 61 73 |f the 31| bit has|
|000012d0| 68 20 66 75 6e 63 74 69 | 6f 6e 2e 20 20 54 68 65 |h functi|on. The|
|000012e0| 20 6c 6f 63 61 74 69 6f | 6e 20 69 6e 20 61 20 62 | locatio|n in a b|
|000012f0| 75 63 6b 65 74 20 69 73 | 20 74 68 65 20 68 61 73 |ucket is| the has|
|00001300| 68 0d 20 20 20 76 61 6c | 75 65 20 6d 6f 64 75 6c |h. val|ue modul|
|00001310| 6f 20 74 68 65 20 73 69 | 7a 65 20 6f 66 20 74 68 |o the si|ze of th|
|00001320| 65 20 62 75 63 6b 65 74 | 2e 20 20 54 68 65 20 69 |e bucket|. The i|
|00001330| 6e 2d 6d 65 6d 6f 72 79 | 20 69 6d 61 67 65 73 20 |n-memory| images |
|00001340| 6f 66 20 74 68 65 0d 20 | 20 20 62 75 63 6b 65 74 |of the. | bucket|
|00001350| 73 20 61 72 65 20 61 6c | 6c 6f 63 61 74 65 64 20 |s are al|located |
|00001360| 62 79 20 6d 61 6c 6c 6f | 63 20 75 73 69 6e 67 20 |by mallo|c using |
|00001370| 61 20 63 61 6c 63 75 6c | 61 74 65 64 20 73 69 7a |a calcul|ated siz|
|00001380| 65 20 64 65 70 65 6e 64 | 69 6e 67 20 6f 66 0d 20 |e depend|ing of. |
|00001390| 20 20 74 68 65 20 66 69 | 6c 65 20 73 79 73 74 65 | the fi|le syste|
|000013a0| 6d 20 62 75 66 66 65 72 | 20 73 69 7a 65 2e 20 20 |m buffer| size. |
|000013b0| 54 6f 20 73 70 65 65 64 | 20 75 70 20 77 72 69 74 |To speed| up writ|
|000013c0| 65 2c 20 65 61 63 68 20 | 62 75 63 6b 65 74 20 77 |e, each |bucket w|
|000013d0| 69 6c 6c 20 68 61 76 65 | 0d 20 20 20 42 55 43 4b |ill have|. BUCK|
|000013e0| 45 54 5f 41 56 41 49 4c | 20 61 76 61 69 6c 20 65 |ET_AVAIL| avail e|
|000013f0| 6c 65 6d 65 6e 74 73 20 | 77 69 74 68 20 74 68 65 |lements |with the|
|00001400| 20 62 75 63 6b 65 74 2e | 20 2a 2f 0d 0d 74 79 70 | bucket.| */..typ|
|00001410| 65 64 65 66 20 73 74 72 | 75 63 74 20 7b 0d 20 20 |edef str|uct {. |
|00001420| 20 20 20 20 20 20 69 6e | 74 20 20 20 61 76 5f 63 | in|t av_c|
|00001430| 6f 75 6e 74 3b 09 09 20 | 20 20 2f 2a 20 54 68 65 |ount;.. | /* The|
|00001440| 20 6e 75 6d 62 65 72 20 | 6f 66 20 62 75 63 6b 65 | number |of bucke|
|00001450| 74 5f 61 76 61 69 6c 20 | 65 6e 74 72 69 65 73 2e |t_avail |entries.|
|00001460| 20 2a 2f 0d 20 20 20 20 | 20 20 20 20 61 76 61 69 | */. | avai|
|00001470| 6c 5f 65 6c 65 6d 20 62 | 75 63 6b 65 74 5f 61 76 |l_elem b|ucket_av|
|00001480| 61 69 6c 5b 42 55 43 4b | 45 54 5f 41 56 41 49 4c |ail[BUCK|ET_AVAIL|
|00001490| 5d 3b 20 20 2f 2a 20 44 | 69 73 74 72 69 62 75 74 |]; /* D|istribut|
|000014a0| 65 64 20 61 76 61 69 6c | 2e 20 2a 2f 0d 09 69 6e |ed avail|. */..in|
|000014b0| 74 20 20 20 62 75 63 6b | 65 74 5f 62 69 74 73 3b |t buck|et_bits;|
|000014c0| 09 20 20 20 2f 2a 20 54 | 68 65 20 6e 75 6d 62 65 |. /* T|he numbe|
|000014d0| 72 20 6f 66 20 62 69 74 | 73 20 75 73 65 64 20 74 |r of bit|s used t|
|000014e0| 6f 20 67 65 74 20 68 65 | 72 65 2e 20 2a 2f 0d 09 |o get he|re. */..|
|000014f0| 69 6e 74 20 20 20 63 6f | 75 6e 74 3b 09 09 20 20 |int co|unt;.. |
|00001500| 20 2f 2a 20 54 68 65 20 | 6e 75 6d 62 65 72 20 6f | /* The |number o|
|00001510| 66 20 65 6c 65 6d 65 6e | 74 20 62 75 63 6b 65 74 |f elemen|t bucket|
|00001520| 73 20 66 75 6c 6c 2e 20 | 2a 2f 0d 09 62 75 63 6b |s full. |*/..buck|
|00001530| 65 74 5f 65 6c 65 6d 65 | 6e 74 20 68 5f 74 61 62 |et_eleme|nt h_tab|
|00001540| 6c 65 5b 31 5d 3b 20 2f | 2a 20 54 68 65 20 74 61 |le[1]; /|* The ta|
|00001550| 62 6c 65 2e 20 20 4d 61 | 6b 65 20 69 74 20 6c 6f |ble. Ma|ke it lo|
|00001560| 6f 6b 20 6c 69 6b 65 20 | 61 6e 20 61 72 72 61 79 |ok like |an array|
|00001570| 2e 2a 2f 0d 20 20 20 20 | 20 20 7d 20 68 61 73 68 |.*/. | } hash|
|00001580| 5f 62 75 63 6b 65 74 3b | 0d 0d 2f 2a 20 57 65 20 |_bucket;|../* We |
|00001590| 77 61 6e 74 20 74 6f 20 | 6b 65 65 70 20 66 72 6f |want to |keep fro|
|000015a0| 6d 20 72 65 61 64 69 6e | 67 20 62 75 63 6b 65 74 |m readin|g bucket|
|000015b0| 73 20 61 73 20 6d 75 63 | 68 20 61 73 20 70 6f 73 |s as muc|h as pos|
|000015c0| 73 69 62 6c 65 2e 20 20 | 54 68 65 20 66 6f 6c 6c |sible. |The foll|
|000015d0| 6f 77 69 6e 67 20 69 73 | 0d 20 20 20 74 6f 20 69 |owing is|. to i|
|000015e0| 6d 70 6c 65 6d 65 6e 74 | 20 61 20 62 75 63 6b 65 |mplement| a bucke|
|000015f0| 74 20 63 61 63 68 65 2e | 20 20 57 68 65 6e 20 66 |t cache.| When f|
|00001600| 75 6c 6c 2c 20 62 75 63 | 6b 65 74 73 20 77 69 6c |ull, buc|kets wil|
|00001610| 6c 20 62 65 20 64 72 6f | 70 70 65 64 20 69 6e 20 |l be dro|pped in |
|00001620| 61 0d 20 20 20 6c 65 61 | 73 74 20 72 65 63 65 6e |a. lea|st recen|
|00001630| 74 6c 79 20 72 65 61 64 | 20 66 72 6f 6d 20 64 69 |tly read| from di|
|00001640| 73 6b 20 6f 72 64 65 72 | 2e 20 20 2a 2f 0d 0d 2f |sk order|. */../|
|00001650| 2a 20 54 6f 20 73 70 65 | 65 64 20 75 70 20 66 65 |* To spe|ed up fe|
|00001660| 74 63 68 69 6e 67 20 61 | 6e 64 20 22 73 65 71 75 |tching a|nd "sequ|
|00001670| 65 6e 74 69 61 6c 22 20 | 61 63 63 65 73 73 2c 20 |ential" |access, |
|00001680| 77 65 20 6e 65 65 64 20 | 74 6f 20 69 6d 70 6c 65 |we need |to imple|
|00001690| 6d 65 6e 74 20 61 0d 20 | 20 20 64 61 74 61 20 63 |ment a. | data c|
|000016a0| 61 63 68 65 20 66 6f 72 | 20 6b 65 79 2f 64 61 74 |ache for| key/dat|
|000016b0| 61 20 70 61 69 72 73 20 | 72 65 61 64 20 66 72 6f |a pairs |read fro|
|000016c0| 6d 20 74 68 65 20 66 69 | 6c 65 2e 20 20 54 6f 20 |m the fi|le. To |
|000016d0| 66 69 6e 64 20 61 20 6b | 65 79 2c 20 77 65 0d 20 |find a k|ey, we. |
|000016e0| 20 20 6d 75 73 74 20 65 | 78 61 63 74 6c 79 20 6d | must e|xactly m|
|000016f0| 61 74 63 68 20 74 68 65 | 20 6b 65 79 20 66 72 6f |atch the| key fro|
|00001700| 6d 20 74 68 65 20 66 69 | 6c 65 2e 20 20 54 6f 20 |m the fi|le. To |
|00001710| 72 65 64 75 63 65 20 6f | 76 65 72 68 65 61 64 2c |reduce o|verhead,|
|00001720| 20 74 68 65 0d 20 20 20 | 64 61 74 61 20 77 69 6c | the. |data wil|
|00001730| 6c 20 62 65 20 72 65 61 | 64 20 61 74 20 74 68 65 |l be rea|d at the|
|00001740| 20 73 61 6d 65 20 74 69 | 6d 65 2e 20 20 42 6f 74 | same ti|me. Bot|
|00001750| 68 20 6b 65 79 20 61 6e | 64 20 64 61 74 61 20 77 |h key an|d data w|
|00001760| 69 6c 6c 20 62 65 20 73 | 74 6f 72 65 64 0d 20 20 |ill be s|tored. |
|00001770| 20 69 6e 20 61 20 64 61 | 74 61 20 63 61 63 68 65 | in a da|ta cache|
|00001780| 2e 20 20 45 61 63 68 20 | 62 75 63 6b 65 74 20 63 |. Each |bucket c|
|00001790| 61 63 68 65 64 20 77 69 | 6c 6c 20 68 61 76 65 20 |ached wi|ll have |
|000017a0| 61 20 6f 6e 65 20 65 6c | 65 6d 65 6e 74 20 64 61 |a one el|ement da|
|000017b0| 74 61 0d 20 20 20 63 61 | 63 68 65 2e 20 20 2a 2f |ta. ca|che. */|
|000017c0| 0d 0d 74 79 70 65 64 65 | 66 20 73 74 72 75 63 74 |..typede|f struct|
|000017d0| 20 7b 0d 20 20 20 20 20 | 20 20 20 6c 6f 6e 67 20 | {. | long |
|000017e0| 20 68 61 73 68 5f 76 61 | 6c 3b 0d 09 69 6e 74 20 | hash_va|l;..int |
|000017f0| 20 20 64 61 74 61 5f 73 | 69 7a 65 3b 0d 09 69 6e | data_s|ize;..in|
|00001800| 74 20 20 20 6b 65 79 5f | 73 69 7a 65 3b 0d 09 63 |t key_|size;..c|
|00001810| 68 61 72 20 2a 64 70 74 | 72 3b 0d 09 69 6e 74 20 |har *dpt|r;..int |
|00001820| 20 20 65 6c 65 6d 5f 6c | 6f 63 3b 0d 20 20 20 20 | elem_l|oc;. |
|00001830| 20 20 7d 20 20 64 61 74 | 61 5f 63 61 63 68 65 5f | } dat|a_cache_|
|00001840| 65 6c 65 6d 3b 0d 0d 74 | 79 70 65 64 65 66 20 73 |elem;..t|ypedef s|
|00001850| 74 72 75 63 74 20 7b 0d | 20 20 20 20 20 20 20 20 |truct {.| |
|00001860| 68 61 73 68 5f 62 75 63 | 6b 65 74 20 2a 20 20 20 |hash_buc|ket * |
|00001870| 63 61 5f 62 75 63 6b 65 | 74 3b 0d 09 6c 6f 6e 67 |ca_bucke|t;..long|
|00001880| 20 20 20 20 20 20 20 20 | 20 20 20 20 63 61 5f 61 | | ca_a|
|00001890| 64 72 3b 0d 09 63 68 61 | 72 09 09 63 61 5f 63 68 |dr;..cha|r..ca_ch|
|000018a0| 61 6e 67 65 64 3b 20 20 | 20 2f 2a 20 44 61 74 61 |anged; | /* Data|
|000018b0| 20 69 6e 20 74 68 65 20 | 62 75 63 6b 65 74 20 63 | in the |bucket c|
|000018c0| 68 61 6e 67 65 64 2e 20 | 2a 2f 0d 09 64 61 74 61 |hanged. |*/..data|
|000018d0| 5f 63 61 63 68 65 5f 65 | 6c 65 6d 20 63 61 5f 64 |_cache_e|lem ca_d|
|000018e0| 61 74 61 3b 0d 20 20 20 | 20 20 20 7d 20 63 61 63 |ata;. | } cac|
|000018f0| 68 65 5f 65 6c 65 6d 3b | 0d 0d 0d 0d 2f 2a 20 54 |he_elem;|..../* T|
|00001900| 68 69 73 20 66 69 6e 61 | 6c 20 73 74 72 75 63 74 |his fina|l struct|
|00001910| 75 72 65 20 63 6f 6e 74 | 61 69 6e 73 20 61 6c 6c |ure cont|ains all|
|00001920| 20 6d 61 69 6e 20 6d 65 | 6d 6f 72 79 20 62 61 73 | main me|mory bas|
|00001930| 65 64 20 69 6e 66 6f 72 | 6d 61 74 69 6f 6e 20 66 |ed infor|mation f|
|00001940| 6f 72 0d 20 20 20 61 20 | 67 64 62 6d 20 66 69 6c |or. a |gdbm fil|
|00001950| 65 2e 20 20 54 68 69 73 | 20 61 6c 6c 6f 77 73 20 |e. This| allows |
|00001960| 6d 75 6c 74 69 70 6c 65 | 20 67 64 62 6d 20 66 69 |multiple| gdbm fi|
|00001970| 6c 65 73 20 74 6f 20 62 | 65 20 6f 70 65 6e 65 64 |les to b|e opened|
|00001980| 20 61 74 20 74 68 65 20 | 73 61 6d 65 0d 20 20 20 | at the |same. |
|00001990| 74 69 6d 65 20 62 79 20 | 6f 6e 65 20 70 72 6f 67 |time by |one prog|
|000019a0| 72 61 6d 2e 20 2a 2f 0d | 0d 74 79 70 65 64 65 66 |ram. */.|.typedef|
|000019b0| 20 73 74 72 75 63 74 20 | 7b 0d 09 2f 2a 20 47 6c | struct |{../* Gl|
|000019c0| 6f 62 61 6c 20 76 61 72 | 69 61 62 6c 65 73 20 61 |obal var|iables a|
|000019d0| 6e 64 20 70 6f 69 6e 74 | 65 72 73 20 74 6f 20 64 |nd point|ers to d|
|000019e0| 79 6e 61 6d 69 63 20 76 | 61 72 69 61 62 6c 65 73 |ynamic v|ariables|
|000019f0| 20 75 73 65 64 20 62 79 | 20 67 64 62 6d 2e 20 20 | used by| gdbm. |
|00001a00| 2a 2f 0d 0d 20 20 09 2f | 2a 20 54 68 65 20 66 69 |*/.. ./|* The fi|
|00001a10| 6c 65 20 6e 61 6d 65 2e | 20 2a 2f 0d 09 63 68 61 |le name.| */..cha|
|00001a20| 72 20 2a 6e 61 6d 65 3b | 0d 0d 09 2f 2a 20 54 68 |r *name;|.../* Th|
|00001a30| 65 20 72 65 61 64 65 72 | 2f 77 72 69 74 65 72 20 |e reader|/writer |
|00001a40| 73 74 61 74 75 73 2e 20 | 2a 2f 0d 09 69 6e 74 20 |status. |*/..int |
|00001a50| 72 65 61 64 5f 77 72 69 | 74 65 3b 0d 0d 09 2f 2a |read_wri|te;.../*|
|00001a60| 20 54 68 65 20 66 61 74 | 61 6c 20 65 72 72 6f 72 | The fat|al error|
|00001a70| 20 68 61 6e 64 6c 69 6e | 67 20 72 6f 75 74 69 6e | handlin|g routin|
|00001a80| 65 2e 20 2a 2f 0d 09 76 | 6f 69 64 20 28 2a 66 61 |e. */..v|oid (*fa|
|00001a90| 74 61 6c 5f 65 72 72 29 | 20 28 29 3b 0d 0d 09 2f |tal_err)| ();.../|
|00001aa0| 2a 20 54 68 65 20 67 64 | 62 6d 20 66 69 6c 65 20 |* The gd|bm file |
|00001ab0| 64 65 73 63 72 69 70 74 | 6f 72 20 77 68 69 63 68 |descript|or which|
|00001ac0| 20 69 73 20 73 65 74 20 | 69 6e 20 67 64 62 6d 5f | is set |in gdbm_|
|00001ad0| 6f 70 65 6e 2e 20 20 2a | 2f 0d 09 69 6e 74 20 20 |open. *|/..int |
|00001ae0| 64 65 73 63 3b 0d 0d 09 | 2f 2a 20 54 68 65 20 66 |desc;...|/* The f|
|00001af0| 69 6c 65 20 68 65 61 64 | 65 72 20 68 6f 6c 64 73 |ile head|er holds|
|00001b00| 20 69 6e 66 6f 72 6d 61 | 74 69 6f 6e 20 61 62 6f | informa|tion abo|
|00001b10| 75 74 20 74 68 65 20 64 | 61 74 61 62 61 73 65 2e |ut the d|atabase.|
|00001b20| 20 2a 2f 0d 09 67 64 62 | 6d 5f 66 69 6c 65 5f 68 | */..gdb|m_file_h|
|00001b30| 65 61 64 65 72 20 2a 68 | 65 61 64 65 72 3b 0d 0d |eader *h|eader;..|
|00001b40| 09 2f 2a 20 54 68 65 20 | 68 61 73 68 20 74 61 62 |./* The |hash tab|
|00001b50| 6c 65 20 64 69 72 65 63 | 74 6f 72 79 20 66 72 6f |le direc|tory fro|
|00001b60| 6d 20 65 78 74 65 6e 64 | 69 62 6c 65 20 68 61 73 |m extend|ible has|
|00001b70| 68 69 6e 67 2e 20 20 53 | 65 65 20 46 61 67 69 6e |hing. S|ee Fagin|
|00001b80| 20 65 74 20 61 6c 2c 20 | 0d 09 20 20 20 41 43 4d | et al, |.. ACM|
|00001b90| 20 54 72 61 6e 73 20 6f | 6e 20 44 61 74 61 62 61 | Trans o|n Databa|
|00001ba0| 73 65 20 53 79 73 74 65 | 6d 73 2c 20 56 6f 6c 20 |se Syste|ms, Vol |
|00001bb0| 34 2c 20 4e 6f 20 33 2e | 20 53 65 70 74 20 31 39 |4, No 3.| Sept 19|
|00001bc0| 37 39 2c 20 33 31 35 2d | 33 34 34 20 2a 2f 0d 09 |79, 315-|344 */..|
|00001bd0| 6c 6f 6e 67 20 20 2a 64 | 69 72 3b 0d 0d 09 2f 2a |long *d|ir;.../*|
|00001be0| 20 54 68 65 20 62 75 63 | 6b 65 74 20 63 61 63 68 | The buc|ket cach|
|00001bf0| 65 2e 20 2a 2f 0d 09 63 | 61 63 68 65 5f 65 6c 65 |e. */..c|ache_ele|
|00001c00| 6d 20 62 75 63 6b 65 74 | 5f 63 61 63 68 65 20 5b |m bucket|_cache [|
|00001c10| 43 41 43 48 45 5f 53 49 | 5a 45 5d 3b 0d 09 69 6e |CACHE_SI|ZE];..in|
|00001c20| 74 20 6c 61 73 74 5f 72 | 65 61 64 3b 0d 0d 09 2f |t last_r|ead;.../|
|00001c30| 2a 20 50 6f 69 6e 74 73 | 20 74 6f 20 74 68 65 20 |* Points| to the |
|00001c40| 63 75 72 72 65 6e 74 20 | 68 61 73 68 20 62 75 63 |current |hash buc|
|00001c50| 6b 65 74 20 69 6e 20 74 | 68 65 20 63 61 63 68 65 |ket in t|he cache|
|00001c60| 2e 20 2a 2f 0d 09 68 61 | 73 68 5f 62 75 63 6b 65 |. */..ha|sh_bucke|
|00001c70| 74 20 2a 62 75 63 6b 65 | 74 3b 0d 0d 09 2f 2a 20 |t *bucke|t;.../* |
|00001c80| 54 68 65 20 64 69 72 65 | 63 74 6f 72 79 20 65 6e |The dire|ctory en|
|00001c90| 74 72 79 20 75 73 65 64 | 20 74 6f 20 67 65 74 20 |try used| to get |
|00001ca0| 74 68 65 20 63 75 72 72 | 65 6e 74 20 68 61 73 68 |the curr|ent hash|
|00001cb0| 20 62 75 63 6b 65 74 2e | 20 2a 2f 0d 09 6c 6f 6e | bucket.| */..lon|
|00001cc0| 67 20 62 75 63 6b 65 74 | 5f 64 69 72 3b 0d 0d 09 |g bucket|_dir;...|
|00001cd0| 2f 2a 20 50 6f 69 6e 74 | 65 72 20 74 6f 20 74 68 |/* Point|er to th|
|00001ce0| 65 20 63 75 72 72 65 6e | 74 20 62 75 63 6b 65 74 |e curren|t bucket|
|00001cf0| 27 73 20 63 61 63 68 65 | 20 65 6e 74 72 79 2e 20 |'s cache| entry. |
|00001d00| 2a 2f 0d 09 63 61 63 68 | 65 5f 65 6c 65 6d 20 2a |*/..cach|e_elem *|
|00001d10| 63 61 63 68 65 5f 65 6e | 74 72 79 3b 0d 0d 0d 09 |cache_en|try;....|
|00001d20| 2f 2a 20 42 6f 6f 6b 6b | 65 65 70 69 6e 67 20 6f |/* Bookk|eeping o|
|00001d30| 66 20 74 68 69 6e 67 73 | 20 74 68 61 74 20 6e 65 |f things| that ne|
|00001d40| 65 64 20 74 6f 20 62 65 | 20 77 72 69 74 74 65 6e |ed to be| written|
|00001d50| 20 62 61 63 6b 20 61 74 | 20 74 68 65 0d 09 20 20 | back at| the.. |
|00001d60| 20 65 6e 64 20 6f 66 20 | 61 6e 20 75 70 64 61 74 | end of |an updat|
|00001d70| 65 2e 20 2a 2f 0d 09 63 | 68 61 72 20 20 68 65 61 |e. */..c|har hea|
|00001d80| 64 65 72 5f 63 68 61 6e | 67 65 64 3b 0d 09 63 68 |der_chan|ged;..ch|
|00001d90| 61 72 20 20 64 69 72 65 | 63 74 6f 72 79 5f 63 68 |ar dire|ctory_ch|
|00001da0| 61 6e 67 65 64 3b 0d 09 | 63 68 61 72 20 20 62 75 |anged;..|char bu|
|00001db0| 63 6b 65 74 5f 63 68 61 | 6e 67 65 64 3b 0d 09 63 |cket_cha|nged;..c|
|00001dc0| 68 61 72 20 20 73 65 63 | 6f 6e 64 5f 63 68 61 6e |har sec|ond_chan|
|00001dd0| 67 65 64 3b 0d 09 0d 20 | 20 20 20 20 20 7d 20 67 |ged;... | } g|
|00001de0| 64 62 6d 5f 66 69 6c 65 | 5f 69 6e 66 6f 3b 0d 0d |dbm_file|_info;..|
|00001df0| 0d 00 00 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |........|........|
|00001e00| 00 00 01 00 00 00 01 6e | 00 00 00 6e 00 00 00 3e |.......n|...n...>|
|00001e10| 4e ba fd d6 4f ef 00 1c | 4c ee 18 00 ff e2 4e 5e |N...O...|L.....N^|
|00001e20| 4e 75 4e 56 00 00 70 00 | 2f 00 2f 2e 00 14 48 6d |NuNV..p.|/./...Hm|
|00001e30| 0a 67 64 62 6d 64 65 66 | 73 2e 68 2d 02 00 00 00 |.gdbmdef|s.h-....|
|00001e40| 54 45 58 54 4d 50 53 20 | 00 00 00 00 00 00 00 00 |TEXTMPS |........|
|00001e50| 00 00 54 45 58 54 4d 50 | 53 20 00 00 00 00 00 00 |..TEXTMP|S ......|
|00001e60| 00 00 00 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |........|........|
|00001e70| 00 00 a6 04 08 2d 00 00 | 1d 71 00 00 01 ac 66 32 |.....-..|.q....f2|
|00001e80| 20 6c 00 02 4a a8 00 28 | 66 54 70 00 30 14 72 01 | l..J..(|fTp.0.r.|
|00001e90| c2 40 70 00 30 01 2f 00 | 48 6d e2 7e 48 c6 2f 06 |.@p.0./.|Hm.~H./.|
|00001ea0| 2f 2e 00 0c 2f 0b 4e ba | ff 7a 70 00 4f ef 00 14 |/.../.N.|.zp.O...|
|00001eb0| 60 2e 4a 47 67 28 70 00 | 30 14 72 01 c2 40 70 00 |`.JGg(p.|0.r..@p.|
|00001ec0| 30 01 2f 00 48 6d e2 a0 | 48 c6 2f 06 2f 2e 00 0c |0./.Hm..|H././...|
|00001ed0| 2f 0b 4e ba ff 4e 70 00 | 4f ef 00 14 60 02 70 01 |/.N..Np.|O...`.p.|
|00001ee0| 4c ee 18 c0 ff f0 4e 5e | 4e 75 4e 56 ff fc 48 e7 |L.....N^|NuNV..H.|
|00001ef0| 03 18 26 6e 00 14 3e 2e | 00 12 20 6b 00 02 70 00 |..&n..>.|.. k..p.|
|00001f00| 00 00 00 48 00 09 4d 6f | 6e 61 63 6f 00 72 75 63 |...H..Mo|naco.ruc|
|00001f10| 74 75 72 65 20 61 6e 64 | 20 63 6f 6e 73 74 61 6e |ture and| constan|
|00001f20| 74 73 2e 20 2a 2f 00 06 | 00 04 00 64 00 1c 01 dd |ts. */..|...d....|
|00001f30| 02 3d 00 64 00 1c 01 dd | 02 3d a7 52 e0 27 00 00 |.=.d....|.=.R.'..|
|00001f40| 05 5f 00 00 05 5f 00 00 | 04 46 01 00 00 00 00 1e |._..._..|.F......|
|00001f50| 00 64 00 1c 01 dd 02 3d | 00 64 00 1c 01 dd 02 3d |.d.....=|.d.....=|
|00001f60| 00 00 04 46 00 00 00 00 | 00 00 00 00 00 00 00 00 |...F....|........|
|00001f70| 01 00 00 00 01 6e 00 00 | 00 6e 00 00 00 3e 00 49 |.....n..|.n...>.I|
|00001f80| aa 38 13 1a 00 00 00 1c | 00 3e 00 00 4d 50 53 52 |.8......|.>..MPSR|
|00001f90| 00 01 00 0a 03 ed ff ff | 00 00 00 00 00 00 00 00 |........|........|
|00001fa0| 03 f0 ff ff 00 00 00 4c | 00 4f de 60 00 00 00 00 |.......L|.O.`....|
|00001fb0| 00 00 00 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |........|........|
|00001fc0| 00 00 00 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |........|........|
|00001fd0| 00 00 00 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |........|........|
|00001fe0| 00 00 00 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |........|........|
|00001ff0| 00 00 00 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |........|........|
+--------+-------------------------+-------------------------+--------+--------+